package com.tianhui.consignortwofei.mvp.ui.adapter;

import android.content.Context;
import android.text.Html;
import android.view.ViewGroup;
import android.widget.TextView;

import com.tianhui.consignortwofei.R;
import com.tianhui.consignortwofei.mvp.model.enty.DispatchDetailInfo;

import org.yczbj.ycrefreshviewlib.adapter.RecyclerArrayAdapter;
import org.yczbj.ycrefreshviewlib.holder.BaseViewHolder;

/**
 * @author fgs
 * @date 2020/9/7
 * @description
 **/
public class DispatchDetailListAdapter extends RecyclerArrayAdapter<DispatchDetailInfo> {
    public DispatchDetailListAdapter(Context context) {
        super(context);
    }

    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        return new DispatchDetailListViewHolder(parent, R.layout.item_dispatch_detail_list);
    }

    private class DispatchDetailListViewHolder extends BaseViewHolder<DispatchDetailInfo> {

        private TextView timeTextView;
        private TextView statusTextView;
        private TextView sourceNumberTextView;
        private TextView dispatchNumberTextView;
        private TextView weightTextView;
        private TextView priceTextView;
        private TextView operatorTextView;

        public DispatchDetailListViewHolder(ViewGroup parent, int res) {
            super(parent, res);
            timeTextView = getView(R.id.item_dispatch_detail_list_timeTextView);
            statusTextView = getView(R.id.item_dispatch_detail_list_statusTextView);
            sourceNumberTextView = getView(R.id.item_dispatch_detail_list_sourceNumberTextView);
            dispatchNumberTextView = getView(R.id.item_dispatch_detail_list_dispatchNumberTextView);
            weightTextView = getView(R.id.item_dispatch_detail_list_weightTextView);
            priceTextView = getView(R.id.item_dispatch_detail_list_priceTextView);
            operatorTextView = getView(R.id.item_dispatch_detail_list_operatorTextView);
        }

        @Override
        public void setData(DispatchDetailInfo data) {
            super.setData(data);
            timeTextView.setText("记录时间：" + data.createTime);
            String status = "状态：<font color='#1F67E0'>" + data.operateAction + "</font>";
//            String status = "状态：<font color='#1F67E0'>" + data.statusMessage + "</font>";
            statusTextView.setText(Html.fromHtml(status));
            sourceNumberTextView.setText("货源单号：" + data.recordId);
            dispatchNumberTextView.setText("调度单号：" + data.transportSourceId);
            weightTextView.setText("重量：" + data.transportSourceWeight + "吨");
            priceTextView.setText("价格：" + data.transportSourcePrice + "元");
            operatorTextView.setText("操作人：" + data.operateName);


        }
    }
}
